package com.ding.demo.jvm;

import java.util.ArrayList;
import java.util.List;

public class OOMObjectTest {

    public byte[] placeholder = new byte[64 * 1024];

    public static void fillHeap(int num) throws InterruptedException {
        List<OOMObjectTest> list = new ArrayList<OOMObjectTest>();

        for (int i = 0; i< num ; i++){
            //稍作延时，令监视曲线的变化更加明显 Thread.sleep(50);
            list.add(new OOMObjectTest());
        }
        System.gc();
    }

    public static void main(String[] args) throws Exception {
        for(int i=0;i<1000;i++){
            fillHeap(1000);
        }

    }
}